package priv.yiyuan.example.design.visitor;

import priv.yiyuan.example.design.visitor.policy.CarInsurance;
import priv.yiyuan.example.design.visitor.policy.HealthInsurance;

/**
 * @author YiYuan
 * @data 2025/7/30
 * @apoNote
 */
public class PremiumCalculatorVisitor implements PolicyVisitor {

    @Override
    public void visit(CarInsurance policy) {
        double premium = policy.getYear() > 2025 ? 800 : 1200;
        System.out.println("Car Insurance Premium: $" + premium);
    }

    @Override
    public void visit(HealthInsurance policy) {
        double premium = policy.isHasPreExistingCondition() ? 500 : 200 + policy.getAge() * 5;
        System.out.println("Health Insurance Premium: $" + premium);
    }
}
